package com.qifan.alb2b.service.resource;

import org.springframework.stereotype.Component;
import org.springframework.web.context.support.WebApplicationObjectSupport;

import com.qifan.alb2b.util.Constants;

/**
 * 资源简单工厂
 * @author hc24
 *
 */
@Component
public class ResourceFactory extends WebApplicationObjectSupport{
	
	/**
	 * 根据type获得资源<br/>
	 * 资源类型： 0:住宿 1:活动 2:早餐 3:午餐 4:晚餐 5:接送 6:导游 7:购物 8:其他
	 * @param type
	 * @return
	 */
	public IResource newResouce(int type){
		switch(type){
			case Constants.RES_TYPE_HOTEL:
				return  (IResource) getWebApplicationContext().getBean("hotelResource");
			case Constants.RES_TYPE_ACTIVITY:
				return  (IResource) getWebApplicationContext().getBean("activityResource");
			case Constants.RES_TYPE_ZAOCAN:
				return  (IResource) getWebApplicationContext().getBean("zaocanRepast");
			case Constants.RES_TYPE_WUCAN:
				return  (IResource) getWebApplicationContext().getBean("wucanRepast");
			case Constants.RES_TYPE_WANCAN:
				return  (IResource) getWebApplicationContext().getBean("wancanRepast");
			case Constants.RES_TYPE_CAR:
				return  (IResource) getWebApplicationContext().getBean("carResource");
			case Constants.RES_TYPE_GUIDE:
				return  (IResource) getWebApplicationContext().getBean("guideResource");
			case Constants.RES_TYPE_SHOPPING:
				return  (IResource) getWebApplicationContext().getBean("shoppingResource");
			case Constants.RES_TYPE_OTHER:
				return  (IResource) getWebApplicationContext().getBean("otherResource");
		}
		return null;
	}
}
